package lagern;

/**
 * Interface definition: Fach.
 * Fach: compartiment
 * 
 * @author OpenORB Compiler
 */
public class _FachStub extends org.omg.CORBA.portable.ObjectImpl
        implements Fach
{
    static final String[] _ids_list =
    {
        "IDL:lagern/Fach:1.0"
    };

    public String[] _ids()
    {
     return _ids_list;
    }

    private final static Class _opsClass = lagern.FachOperations.class;

    /**
     * Read accessor for anzahl attribute
     * anzahl = number
     * @return the attribute value
     */
    public int anzahl()
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try {
                    org.omg.CORBA.portable.OutputStream _output = this._request("_get_anzahl",true);
                    _input = this._invoke(_output);
                    return _input.read_long();
                } catch (final org.omg.CORBA.portable.RemarshalException _exception) {
                    continue;
                } catch (final org.omg.CORBA.portable.ApplicationException _exception) {
                    final String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                } finally {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("_get_anzahl",_opsClass);
                if (_so == null)
                   continue;
                lagern.FachOperations _self = (lagern.FachOperations) _so.servant;
                try
                {
                    return _self.anzahl();
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Read accessor for name attribute
     * @return the attribute value
     */
    public String name()
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try {
                    org.omg.CORBA.portable.OutputStream _output = this._request("_get_name",true);
                    _input = this._invoke(_output);
                    return _input.read_string();
                } catch (final org.omg.CORBA.portable.RemarshalException _exception) {
                    continue;
                } catch (final org.omg.CORBA.portable.ApplicationException _exception) {
                    final String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                } finally {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("_get_name",_opsClass);
                if (_so == null)
                   continue;
                lagern.FachOperations _self = (lagern.FachOperations) _so.servant;
                try
                {
                    return _self.name();
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation einlagern
     */
    public void einlagern(String user, int anzahl)
        throws lagern.FachPackage.exInvalidCount
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("einlagern",true);
                    _output.write_string(user);
                    _output.write_long(anzahl);
                    _input = this._invoke(_output);
                    return;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    if (_exception_id.equals(lagern.FachPackage.exInvalidCountHelper.id()))
                    {
                        throw lagern.FachPackage.exInvalidCountHelper.read(_exception.getInputStream());
                    }

                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("einlagern",_opsClass);
                if (_so == null)
                   continue;
                lagern.FachOperations _self = (lagern.FachOperations) _so.servant;
                try
                {
                    _self.einlagern( user,  anzahl);
                    return;
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation auslagern
     */
    public void auslagern(String user, int anzahl)
        throws lagern.FachPackage.exInvalidCount, lagern.FachPackage.exNotEnoughPieces
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("auslagern",true);
                    _output.write_string(user);
                    _output.write_long(anzahl);
                    _input = this._invoke(_output);
                    return;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    if (_exception_id.equals(lagern.FachPackage.exInvalidCountHelper.id()))
                    {
                        throw lagern.FachPackage.exInvalidCountHelper.read(_exception.getInputStream());
                    }

                    if (_exception_id.equals(lagern.FachPackage.exNotEnoughPiecesHelper.id()))
                    {
                        throw lagern.FachPackage.exNotEnoughPiecesHelper.read(_exception.getInputStream());
                    }

                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("auslagern",_opsClass);
                if (_so == null)
                   continue;
                lagern.FachOperations _self = (lagern.FachOperations) _so.servant;
                try
                {
                    _self.auslagern( user,  anzahl);
                    return;
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

}
